{extend name="public/base"/}
{block name="css"}

{/block}
{block name="body"}
<van-nav-bar
        class="nav-theme"
        :fixed="true"
        :placeholder="true"
        left-text="返回"
        left-arrow
        @click-left="onBack"
>
    <template #title>
        <span class="text-white">意见反馈</span>
    </template>
</van-nav-bar>
<van-form @submit="onSubmit">
    <van-cell-group>
        <van-field
                v-model="form.name"
                required
                label="姓名"
                placeholder="请输入姓名"
                :rules="[{ required: true, message: '请输入姓名' }]"
        ></van-field>
        <van-field
                v-model="form.mobile"
                required
                label="联系方式"
                placeholder="请输入联系方式"
                :rules="[{ required: true, message: '请输入联系方式' }]"
        ></van-field>
        <van-field
                v-model="form.content"
                rows="2"
                required
                autosize
                label="意见和建议"
                type="textarea"
                placeholder="请输入您的意见和建议"
                :rules="[{ required: true, message: '请输入意见和建议' }]"
        ></van-field>
    </van-cell-group>
    <div style="margin: 16px;">
        <van-button round block type="primary" native-type="submit">
            提交
        </van-button>
    </div>
</van-form>
{/block}
{block name="script"}
<script>
    function v_setup() {
        let base = {};

        base.form = Vue.reactive({
            name: '',
            mobile: '',
            content: '',
        });
        base.onBack = () => {
            location.href = "{:url('my/index')}";
        };

        //表单提交
        base.onSubmit = () => {
            postJson('/my/feedbackPost',base.form).then(() => {
                vant.showDialog({
                    title: '提示',
                    message: '提交成功',
                }).then(() => {
                    location.href = "{:url('my/index')}";
                });
            });
        };

        return base;
    }
</script>
{/block}